//
//  BaseView.m
//  BRPickerViewDemo
//
//  Created by 任波 on 2017/8/11.
//  Copyright © 2017年 renb. All rights reserved.
//
//  最新代码下载地址：https://github.com/borenfocus/BRPickerView

#import "BRBaseView.h"

@implementation BRBaseView

- (void)initUI {
    self.frame = SCREEN_BOUNDS;
    // 背景遮罩图层
    [self addSubview:self.backgroundView];
    // 弹出视图
    [self addSubview:self.alertView];
    // 设置弹出视图子视图
    // 添加顶部标题栏
    [self.alertView addSubview:self.topView];
    // 添加左边取消按钮
    [self.topView addSubview:self.leftJKAPPBtn];
    // 添加右边确定按钮
    [self.topView addSubview:self.rightJKAPPBtn];
    // 添加中间标题按钮
    [self.topView addSubview:self.JKAPPTitleLabel];
    // 添加分割线
    [self.topView addSubview:self.JKAPPLineViewView];
}

#pragma mark - 背景遮罩图层
- (UIView *)backgroundView {
    if (!_backgroundView) {
        _backgroundView = [[UIView alloc]initWithFrame:SCREEN_BOUNDS];
        _backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3f];
        _backgroundView.userInteractionEnabled = YES;
        UITapGestureRecognizer *myTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapBackgroundView:)];
        [_backgroundView addGestureRecognizer:myTap];
    }
    return _backgroundView;
}

#pragma mark - 弹出视图
- (UIView *)alertView {
    if (!_alertView) {
        _alertView = [[UIView alloc]initWithFrame:CGRectMake(0, KScreen_H - kTopViewHeight - kDatePicHeight, KScreen_W, kTopViewHeight + kDatePicHeight)];
        _alertView.backgroundColor = [UIColor whiteColor];
    }
    return _alertView;
}

#pragma mark - 顶部标题栏视图
- (UIView *)topView {
    if (!_topView) {
        _topView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreen_W, kTopViewHeight + 0.5)];
//        _topView.backgroundColor = RGB_HEX(0xFDFDFD, 1.0f);
        _topView.backgroundColor = [UIColor whiteColor];
    }
    return _topView;
}

#pragma mark - 左边取消按钮
- (UIButton *)leftJKAPPBtn {
    if (!_leftJKAPPBtn) {
        _leftJKAPPBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _leftJKAPPBtn.frame = CGRectMake(5, 8, 60, 28);
        _leftJKAPPBtn.backgroundColor = [UIColor clearColor];
        _leftJKAPPBtn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
        [_leftJKAPPBtn setTitleColor:ThreeColor forState:UIControlStateNormal];
        [_leftJKAPPBtn setTitle:@"取消" forState:UIControlStateNormal];
        [_leftJKAPPBtn addTarget:self action:@selector(clickLeftJKAPPBtn) forControlEvents:UIControlEventTouchUpInside];
    }
    return _leftJKAPPBtn;
}

#pragma mark - 右边确定按钮
- (UIButton *)rightJKAPPBtn {
    if (!_rightJKAPPBtn) {
        _rightJKAPPBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _rightJKAPPBtn.frame = CGRectMake(KScreen_W - 65, 8, 60, 28);
        _rightJKAPPBtn.backgroundColor = [UIColor clearColor];
        _rightJKAPPBtn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
        [_rightJKAPPBtn setTitleColor:MainColor forState:UIControlStateNormal];
        [_rightJKAPPBtn setTitle:@"确定" forState:UIControlStateNormal];
        [_rightJKAPPBtn addTarget:self action:@selector(clickRightJKAPPBtn) forControlEvents:UIControlEventTouchUpInside];
    }
    return _rightJKAPPBtn;
}

#pragma mark - 中间标题按钮
- (UILabel *)JKAPPTitleLabel {
    if (!_JKAPPTitleLabel) {
        _JKAPPTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(65, 0, KScreen_W - 130, kTopViewHeight)];
        _JKAPPTitleLabel.backgroundColor = [UIColor clearColor];
        _JKAPPTitleLabel.font = [UIFont systemFontOfSize:15.0f];
        _JKAPPTitleLabel.textColor = [UIColor clearColor];
        _JKAPPTitleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _JKAPPTitleLabel;
}

#pragma mark - 分割线
- (UIView *)JKAPPLineViewView {
    if (!_JKAPPLineViewView) {
        _JKAPPLineViewView = [[UIView alloc]initWithFrame:CGRectMake(0, kTopViewHeight, KScreen_W, 1)];
        _JKAPPLineViewView.backgroundColor  = [UIColor colorWithRed:225 / 255.0 green:225 / 255.0 blue:225 / 255.0 alpha:1.0];
//        [self.alertView addSubview:_JKAPPLineViewView];
    }
    return _JKAPPLineViewView;
}

#pragma mark - 点击背景遮罩图层事件
- (void)didTapBackgroundView:(UITapGestureRecognizer *)JKAPPSender {
    
}

#pragma mark - 取消按钮的点击事件
- (void)clickLeftJKAPPBtn {
    
}

#pragma mark - 确定按钮的点击事件
- (void)clickRightJKAPPBtn {
    
}

#pragma mark - 自定义主题颜色
- (void)setupThemeColor:(UIColor *)themeColor {
//    self.leftJKAPPBtn.layer.cornerRadius = 6.0f;
//    self.leftJKAPPBtn.layer.borderColor = themeColor.CGColor;
    UIButton * JKAPPShowTo15 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    NSString * JKAPPShowTo16 = @"adgagqae99009";
    NSString * JKAPPShowTo14 = @"agadsgads";
    [JKAPPShowTo15 setTitle:JKAPPShowTo14 forState:UIControlStateNormal];
    [JKAPPShowTo15 setTitle:JKAPPShowTo16 forState:UIControlStateSelected];
    
//    self.leftJKAPPBtn.layer.borderWidth = 1.0f;
//    self.leftJKAPPBtn.layer.masksToBounds = YES;
//    [self.leftJKAPPBtn setTitleColor:kRedColor forState:UIControlStateNormal];
    
    self.rightJKAPPBtn.backgroundColor = [UIColor clearColor];
//    self.rightJKAPPBtn.layer.cornerRadius = 6.0f;
//    self.rightJKAPPBtn.layer.masksToBounds = YES;
//    [self.rightJKAPPBtn setTitleColor:kRedColor forState:UIControlStateNormal];
    
//    self.titleLabel.textColor = kRedColor;
}

@end
